// 文件名：week1\problem\lc11_欧琳琳.cpp
// 提交链接：https://leetcode.cn/problems/container-with-most-water/submissions/559811832?envType=problem-list-v2&envId=two-pointers
// 11. 贪心，数组，双指针
// 完成日期：2024/08/30
// c++,双指针start和end，根据当前的高度值决定移动哪个指针，哪个矮移动哪个

class Solution {
public:
    int maxArea(vector<int>& height) {
        int n = height.size();
        int maxArea = 0;
        
        for (int start = 0, end = n - 1; start < end;) {
            int h = min(height[start], height[end]);
            int width = end - start;
            maxArea = max(maxArea, h * width);
            
            if (height[start] < height[end]) {
                start++;
            } else {
                end--;
            }
        }
        
        return maxArea;
    }
};

